#pragma once

#include <cstdint>
#include <optional>
#include <string>

typedef struct {
	uint8_t button_pressed;
} __attribute__((packed)) incoming_msg;

typedef struct {
	uint8_t led_on;
} __attribute__((packed)) outgoing_msg;

class DemoBoard {
  public:
	DemoBoard(const std::string &path);
    ~DemoBoard();
	std::optional<incoming_msg> poll_message();
	void send_message(const outgoing_msg &msg_out);

  private:
    static constexpr size_t READ_BUF_SIZE = 4096;
	int fd;
	incoming_msg msg;
	ssize_t msg_len;
    char read_buf[READ_BUF_SIZE];
    bool received_byte(char b);
};
